<?php
class Article extends Doctrine_Record
{
    public function setTableDefinition()
    {
    	$this->setTableName('article');

        $this->hasColumn('author_id', 'integer');
        $this->hasColumn('category_id', 'integer');
        $this->hasColumn('title', 'string', 255, array('notblank' => true));
        $this->hasColumn('content', 'string', null, array('notblank' => true));
    }

    public function setUp()
    {
        $this->hasOne('User as author',array(
                'local'=>'author_id',
                'foreign'=>'id'
        ));

        $this->hasOne('Category as category', array(
                'local'=>'category_id',
                'foreign'=>'id'
        ));

        $this->hasMany('Picture as pictures', array(
                'local'=>'id',
                'foreign'=>'article_id'
        ));

        $this->actAs('Timestampable',
            array('updated' => array('onInsert' => false)));
    }
}
?>